<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title><?php echo $WEBSITE['website_name']?>查看骑手位置</title>
<link href="webroot/shop/shop.css?v=<?php echo constant('JSCSS_VERSION')?>" type="text/css" rel="stylesheet">
<script src="webroot/common/jquery-1.12.1.min.js?v=<?php echo constant('JSCSS_VERSION')?>" type="text/javascript"></script>
<style type="text/css">
body{ background:#E7DAEF;}
</style>


<div class="content pstz_top">查看订单配送骑手位置</div>
<div class="content pstz_sign">
	<form action="" method="get">
    	<div class="box"><input class="text text_p" name="phone" type="text" placeholder="请输入订购者或收货人手机号"/></div>
        <div class="box"><input class="text text1" name="checkcode" type="text" placeholder="请输入验证码" /><span onclick="djs(this)" disabled="disabled" id="bnt_yzm">获取验证码</span></div>
        <div class="box"><a class="bnt" href="javascript:void(0)" onclick="check(this)">立即查看</a></div>
    </form>
</div>

<div class="pstz_ico"><img src="webroot/users/images/pstz_ico.gif"></div>

<script>
    var short_link = '<?php echo $short_link;?>';
    var time = 60;
    var seconds = time;
    function djs(){
        var phone =  $(".text_p").val();
        if(checkPhone(phone) == false){
            alert("手机号码有误，请重填");
            return
        }
        if(seconds === 60){
            $.ajax({
                url:"?md=riders&cl=riders&at=creatCode",
                type:"post",
                dataType:"json",
                data:{"phone":phone},
            });
        }

        if (seconds > 1){
            seconds--;
            $("#bnt_yzm").text("("+seconds+"秒)后可重新获取 ").attr("disabled", true).css("pointer-events","none");
            setTimeout(function(){
                djs();
            },1000);
        }else{
            $("#bnt_yzm").text("免费获取验证码").attr("disabled", false).css('pointer-events','');
            seconds = time;
        }
    }


    function checkPhone(phone){
        if(!(/^1[3456789]\d{9}$/.test(phone))){
            return false;
        }else{
            return true;
        }
    }


  function check() {
      let checkcode = $(".text1").val();
      let phone = $(".text_p").val();
      if(checkPhone(phone) == false){
          alert("手机号码有误，请重填");
          return
      }

      if(!checkcode){
          alert("请填写验证码");
          return
      }
      if(!short_link){
          alert("系统参数异常");
          return
      }
      $.ajax({
          url:"?md=service&cl=service&at=CheckPhone2",
          type:"post",
          dataType:"json",
          data:{"phone":phone,checkcode:checkcode,short_link:short_link},
          success:function (d) {
              if(d.status == 'success'){
                  location.href = '?md=service&cl=service&at=Location&short_link='+short_link;
              }else{
                  alert(d.msg)
              }
          }
      });
  }
</script>